package com.jiang.annotation.aop.global_exception_handle;

import io.swagger.v3.oas.annotations.media.Schema;

/**
 * @Author Administrator
 * @Date 2023 12 15 10 34
 **/
public enum ResultStatus {
    OK(200, "成功"),
    FAIL(500, "失败"),
    UNAUTHORIZED(401, "未经授权，无法访问"),
    WARNING(501, "警告");

    @Schema(
            title = "结果代码"
    )
    private final int code;
    @Schema(
            title = "结果信息"
    )
    private final String message;

    private ResultStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ResultStatus getResultEnum(int code) {
        ResultStatus[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ResultStatus type = var1[var3];
            if (type.getCode() == code) {
                return type;
            }
        }

        return FAIL;
    }

    public static ResultStatus getResultEnum(String message) {
        ResultStatus[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ResultStatus type = var1[var3];
            if (type.getMessage().equals(message)) {
                return type;
            }
        }

        return FAIL;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }
}